#ifndef __DBROLE_ENTER_SUCCESSSENDER_H__
#define __DBROLE_ENTER_SUCCESSSENDER_H__

#include "gwmessagemap.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "netlib.h"
#include "../DBServer.h"
#include "dbserver.pb.h"
#include "../../Sender/DBServerSender.h"

/**
*@file       DBRole_Enter_SuccessSender.h
*@brief      send message DBRole_Enter_Success
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/28
*/

///message wrapper
class msgDBRole_Enter_Success
{
public:
    static const int MessageId = DBRole_Enter_Success;
    //TODO
    pnSessionHandle     SessionId;
    DBRoleEnterSuccess  MsgContent;
    ///@brief   constructor
    msgDBRole_Enter_Success(int session_id, int gate_code, int usr_id, const std::string& usr_name, const std::string& role_code, const std::string& role_name,
                            int gender, int job, int world_id, RoleInfoDetail_DataDetail* role_detail):
    SessionId(session_id)
    {
        MsgContent.set_gatecode(gate_code);

        RoleInfoDetail* info = MsgContent.mutable_roleinfo();
        info->set_usrid(usr_id);
        info->set_usrname(usr_name);
        info->set_rolecode(role_code);
        info->set_rolename(role_name);
        info->set_gender(gender);
        info->set_jobtype(job);
        info->set_worldid(world_id);
        RoleInfoDetail_DataDetail* detail = info->mutable_detaildata();
        *detail = *role_detail;
    }
};

class HandleDBRole_Enter_Success
{
public:
    ///@brief     handle message
    ///param[in]  msg     message wrapper of DBRole_Enter_Success
    ///retval     void
    static void HandleMessage(msgDBRole_Enter_Success* msg)
    {
        //TODO
        //Main Message:  msgDBServer
        msgDBServer mainMsg(msg->SessionId, msgDBRole_Enter_Success::MessageId, ProtoNet<DBRoleEnterSuccess>::IntoBytes(msg->MsgContent));
        gwMessagePort::ProcessMessage(&mainMsg);
    }
};
///[message wrapper]  [handler]
RegisterHandler(msgDBRole_Enter_Success, HandleDBRole_Enter_Success);

#endif
